/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package chatlink;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 *
 * @author Nguyen Van Thoi
 */
public class StreamData<T> {

    public static <T> void WriteObject(ObjectOutputStream oos, T object)
            throws IOException {
        oos.writeObject(object);
        oos.flush();
        oos.reset();
    }

    public static <T> Object ReadObject(ObjectInputStream ois)
            throws ClassNotFoundException, IOException {
        return (T) ois.readObject();
    }

    public static <T> void CloseStream(ObjectOutputStream oos, ObjectInputStream ois)
            throws IOException {
        if (oos != null) {
            oos.close();
        }
        if (ois != null) {
            ois.close();
        }
    }
}
